package com.homework.ab_if.test2;

import java.util.Scanner;

public class Gardener {


  public Fruit create(String s) {
    if (s.equals("苹果")) {
      return new Apple();
    }
    if (s.equals("桔子")) {
      return new Orange();
    }
    if (s.equals("梨子")) {
      return new Orange();
    }
    System.out.println("无法创建这个水果。");
    return null;
  }

  public static void main(String[] args) {
    //
    Scanner scanner = new Scanner(System.in);
    Gardener gardener = new Gardener();
    System.out.print("创建个什么呢?");
    String s = scanner.next();
    gardener.create(s);

  }
}
